package com.bdilab.iot.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bdilab.iot.model.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author WangNing
 * @version 1.0
 * @date 2020/7/31 16:52
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("select * from permission")
    List<Permission> getAllPermission();

    @Select("select `id` from permission")
    List<Long> getAllPermissionID();

    @Select("select p.id as id, p.name as name, p.create_time as create_time from permission as p\n" +
            "left join role_permission_relation rpr on rpr.permission_id = p.id\n" +
            "where rpr.role_id = #{roleId}")
    List<Permission> getByRoleId(Long roleId);

    List<Permission> selectByRoles(List<Long> roleIds);
}
